From cd3f046419e31a4585bcb12f3946846378c8b0e3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 30 Nov 2015 11:21:04 -0800 Subject: [PATCH] Update plugin tests to nightly --- Makefile.in | 4 ++-- appveyor.yml | 2 +- src/etc/dl-snapshot.py | 2 +- src/etc/download.py | 31 +++++++++++++++---------- src/etc/install-deps.py | 35 +++++++++++------------------ src/rustversion.txt | 2 +- tests/test_cargo_compile_plugins.rs | 8 +++---- tests/test_cargo_cross_compile.rs | 12 +++++----- 8 files changed, 47 insertions(+), 49 deletions(-) diff --git a/Makefile.in b/Makefile.in index bd7f915e6..8661589a3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -75,7 +75,7 @@ $(foreach target,$(CFG_TARGET),$(eval $(call DIST_TARGET,$(target)))) ifdef CFG_LOCAL_CARGO CARGO := $(CFG_LOCAL_CARGO) else -CARGO := $(TARGET_ROOT)/snapshot/cargo/bin/cargo$(X) +CARGO := $(TARGET_ROOT)/snapshot/bin/cargo$(X) endif all: $(foreach target,$(CFG_TARGET),cargo-$(target)) @@ -92,7 +92,7 @@ test-unit-$(1): $$(CARGO) endef $(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target)))) -$(TARGET_ROOT)/snapshot/cargo/bin/cargo$(X): src/snapshots.txt +$(TARGET_ROOT)/snapshot/bin/cargo$(X): src/snapshots.txt $(CFG_PYTHON) src/etc/dl-snapshot.py $(CFG_BUILD) touch $@ diff --git a/appveyor.yml b/appveyor.yml index 18fc5f2fd..39c11e1f7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ install: - python src/etc/dl-snapshot.py %TARGET% - call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %ARCH% - SET PATH=%PATH%;%cd%/rustc/bin - - SET PATH=%PATH%;%cd%/target/snapshot/cargo/bin + - SET PATH=%PATH%;%cd%/target/snapshot/bin - if defined NEEDS_LIBGCC set PATH=%PATH%;C:\MinGW\bin - rustc -V - cargo -V diff --git a/src/etc/dl-snapshot.py b/src/etc/dl-snapshot.py index b279f536a..c43f47fd6 100644 --- a/src/etc/dl-snapshot.py +++ b/src/etc/dl-snapshot.py @@ -93,4 +93,4 @@ if not exists: if h != hash: raise Exception("failed to verify the checksum of the snapshot") -download.unpack(dl_path, dst) +download.unpack(dl_path, dst, strip=2) diff --git a/src/etc/download.py b/src/etc/download.py index 807273782..d61e9fa8f 100644 --- a/src/etc/download.py +++ b/src/etc/download.py @@ -16,22 +16,29 @@ def get(url, path, quiet=False): run(["curl", "-o", path, url], quiet=quiet) -def unpack(tarball, dst, quiet=False): +def unpack(tarball, dst, quiet=False, strip=0): if quiet: print("extracting " + tarball) - fname = os.path.basename(tarball).replace(".tar.gz", "") with contextlib.closing(tarfile.open(tarball)) as tar: - for p in tar.getnames(): - name = p.replace(fname + "/", "", 1) - fp = os.path.join(dst, name) - if not quiet: - print("extracting " + p) - tar.extract(p, dst) - tp = os.path.join(dst, p) - if os.path.isdir(tp) and os.path.exists(fp): + for p in tar.getmembers(): + if p.isdir(): + continue + path = [] + p2 = p.name + while p2 != "": + a, b = os.path.split(p2) + path.insert(0, b) + p2 = a + if len(path) <= strip: continue - shutil.move(tp, fp) - shutil.rmtree(os.path.join(dst, fname)) + fp = os.path.join(dst, *path[strip:]) + if not quiet: + print("extracting " + p.name) + contents = tar.extractfile(p) + if not os.path.exists(os.path.dirname(fp)): + os.makedirs(os.path.dirname(fp)) + open(fp, 'wb').write(contents.read()) + os.chmod(fp, p.mode) def run(args, quiet=False): diff --git a/src/etc/install-deps.py b/src/etc/install-deps.py index 1d73f69ca..28a4fb7b1 100644 --- a/src/etc/install-deps.py +++ b/src/etc/install-deps.py @@ -15,7 +15,6 @@ else: extra_bits = 'i686' extra = None -libdir = 'lib' # Figure out our target triple if sys.platform == 'linux' or sys.platform == 'linux2': @@ -25,7 +24,6 @@ elif sys.platform == 'darwin': host = host_bits + '-apple-darwin' extra = extra_bits + '-apple-darwin' elif sys.platform == 'win32': - libdir = 'bin' if os.environ.get('MSVC') == '1': host = host_bits + '-pc-windows-msvc' extra = extra_bits + '-pc-windows-msvc' @@ -42,33 +40,26 @@ def install_via_tarballs(): if os.path.isdir("rustc-install"): shutil.rmtree("rustc-install") + # Download the compiler host_fname = 'rustc-nightly-' + host + '.tar.gz' download.get(url + '/' + host_fname, host_fname) - download.unpack(host_fname, "rustc-install", quiet=True) + download.unpack(host_fname, "rustc-install", quiet=True, strip=2) os.remove(host_fname) + # Download all target libraries needed + fetch_std(host) if extra is not None: - extra_fname = 'rustc-nightly-' + extra + '.tar.gz' - print("adding target libs for " + extra) - download.get(url + '/' + extra_fname, extra_fname) - folder = extra_fname.replace(".tar.gz", "") - with contextlib.closing(tarfile.open(extra_fname)) as tar: - for p in tar.getnames(): - if not "rustc/" + libdir + "/rustlib/" + extra in p: - continue - name = p.replace(folder + "/", "", 1) - dst = "rustc-install/" + name - tar.extract(p, "rustc-install") - tp = os.path.join("rustc-install", p) - if os.path.isdir(tp) and os.path.exists(dst): - continue - shutil.move(tp, dst) - shutil.rmtree("rustc-install/" + folder) - os.remove(extra_fname) + fetch_std(extra) if os.path.isdir("rustc"): shutil.rmtree("rustc") - os.rename("rustc-install/rustc", "rustc") - shutil.rmtree("rustc-install") + os.rename("rustc-install", "rustc") + +def fetch_std(target): + fname = 'rust-std-nightly-' + target + '.tar.gz' + print("adding target libs for " + target) + download.get(url + '/' + fname, fname) + download.unpack(fname, "rustc-install", quiet=True, strip=2) + os.remove(fname) install_via_tarballs() diff --git a/src/rustversion.txt b/src/rustversion.txt index 7063ccdca..5fdf51cb8 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2015-10-17 +2015-11-30 diff --git a/tests/test_cargo_compile_plugins.rs b/tests/test_cargo_compile_plugins.rs index 670f4a63b..dca74a6df 100644 --- a/tests/test_cargo_compile_plugins.rs +++ b/tests/test_cargo_compile_plugins.rs @@ -54,10 +54,10 @@ test!(plugin_to_the_max { .file("src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] - extern crate rustc; + extern crate rustc_plugin; extern crate baz; - use rustc::plugin::Registry; + use rustc_plugin::Registry; #[plugin_registrar] pub fn foo(_reg: &mut Registry) { @@ -154,9 +154,9 @@ test!(plugin_with_dynamic_native_dependency { "#) .file("bar/src/lib.rs", &format!(r#" #![feature(plugin_registrar, rustc_private)] - extern crate rustc; + extern crate rustc_plugin; - use rustc::plugin::Registry; + use rustc_plugin::Registry; #[link(name = "{}")] extern {{ fn foo(); }} diff --git a/tests/test_cargo_cross_compile.rs b/tests/test_cargo_cross_compile.rs index 3d4174afb..06686bf90 100644 --- a/tests/test_cargo_cross_compile.rs +++ b/tests/test_cargo_cross_compile.rs @@ -153,10 +153,10 @@ test!(plugin_deps { .file("src/lib.rs", r#" #![feature(plugin_registrar, quote, rustc_private)] - extern crate rustc; + extern crate rustc_plugin; extern crate syntax; - use rustc::plugin::Registry; + use rustc_plugin::Registry; use syntax::ast::TokenTree; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, MacEager, MacResult}; @@ -233,11 +233,11 @@ test!(plugin_to_the_max { .file("src/lib.rs", r#" #![feature(plugin_registrar, quote, rustc_private)] - extern crate rustc; + extern crate rustc_plugin; extern crate syntax; extern crate baz; - use rustc::plugin::Registry; + use rustc_plugin::Registry; use syntax::ast::TokenTree; use syntax::codemap::Span; use syntax::ext::base::{ExtCtxt, MacEager, MacResult}; @@ -352,10 +352,10 @@ test!(plugin_with_extra_dylib_dep { .file("src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] - extern crate rustc; + extern crate rustc_plugin; extern crate baz; - use rustc::plugin::Registry; + use rustc_plugin::Registry; #[plugin_registrar] pub fn foo(reg: &mut Registry) { -- 2.30.2